define(function(require, exports){
	var $ = require('jquery');
	var pubjs = require('pubjs');
	var util = require('util');
	var baseGrid = require('@base/grid').baseNoDate;

	var Base = baseGrid.extend({
		init: function(config){
			config = pubjs.conf(config, {
				'cols': [
					{"name":"_id", "text": LANG('SID')}
					,{"type": "op", "render": 'renderOp'}
					,{"name":"loginId", "text": LANG('登录Id')}
					,{"name": "currentId","text":LANG("DspUser Id")}
					,{"name": "login","text":LANG("登录者名称"), render: 'renderLogin'}
					,{"name": "rights","text":LANG("拥有的权限点"), render: 'renderRight'}
					,{"name": "products","text":LANG("可登录产品"), render: 'renderProduct'}
				]
				,"opClick": true
				,'hasSearch': false
				,'hasTab': false
				,'hasExport': false
				,'hasAmount': false
				,'hasRefresh': true
				,'url': 'blackMagic/session'
				,'sub_field': '_id'
				,'reqType': 'websocket'
				,'pager': {'size':10}
				,'param' :{
					'Type': 1,
					'noAmount': true
				}
				,'gridName': 'blackMagic'
			});

			this.Super('init', arguments);
		}
		,renderLogin: function(idx, val, row) {
			return row && row.login && (row.login.name + ' - ' + row.login.email);
		}
		,renderProduct: function(idx, val) {
			if(val && val.length)
			{
				var ret = [];
				util.each(val, function(item) {
					ret.push(item.name);
				});

				ret = ret.join(' | ');
				return [
					"<div class='uk-text-truncate' style='width: 200px' title='",ret ,"'>",
						"<span>",
							ret,
						"</span>",
					"</div>"].join('');
			}
			else
			{
				return '-';
			}
		}
		,renderRight: function(idx, val) {
			return '权限点数量：' + (val && val.length);
		}
		,renderOp: function() {
			if(pubjs.checkRight('master.sunfei'))
			{
				return ['<a data-op="kick" title="'+LANG("踢出")+'">'+LANG("Kick Out")+'</a>'
					,'<a data-op="right" title="'+LANG("编辑权限")+'">'+LANG("编辑权限")+'</a>'
				].join('|')
			}
		}
	});

	exports.base = Base;

});